package com.iv.durian.cloud.facade.support;

import com.iv.durian.cloud.Lesson;
import com.iv.durian.cloud.facade.LessonFacade;
import com.iv.durian.cloud.service.LessonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by zlw on 2018-06-30.
 */
@Slf4j
@RestController
public class LessonFacadeImpl implements LessonFacade {

    @Autowired
    private LessonService lessonService;

    @Override
    public Lesson getById(@PathVariable(name = "lesson_id") Integer lessonId) {
        return lessonService.get(lessonId);
    }

    @Override
    public Lesson getByName(@PathVariable(name = "lesson_name") String name) {
        return lessonService.get(name);
    }

    @Override
    public void add(@RequestBody Lesson lesson) {
        lessonService.add(lesson);
    }

    @Override
    public void removeById(@PathVariable(name = "lesson_id") Integer lessonId) {
        lessonService.removeLessonById(lessonId);
    }

    @Override
    public void removeByName(@PathVariable(name = "name") String name) {
        lessonService.removeLessonByName(name);
    }

    @Override
    public int updateLessonName(@PathVariable(name = "lesson_id")Integer id, @PathVariable(name = "lesson_name")String lessonName) {
        return lessonService.updateLessonName(id, lessonName);
    }

    @Override
    public List<Lesson> list(@PathVariable("status")Integer status, @PathVariable("offset")Integer offset, @PathVariable("limit")Integer limit) {
        return lessonService.list(status, offset, limit);
    }

    @Override
    public int count(@PathVariable("status")Integer status) {
        return lessonService.count(status);
    }
}
